(deftemplate number (slot pi) (slot pz))
(deftemplate suma (slot pi) (slot pz))

(assert (number (pi 1) (pz 0)))
(assert (number (pi 2) (pz 7)))
(assert (number (pi 5) (pz 12)))
(assert (number (pi 6) (pz 12345)))
(assert (suma (pi 0) (pz 0)))

(defrule printare
(number (pi ?i) (pz ?z))
=>
(printout t "Nr " ?i "," ?z crlf)
)

(defrule suma
	?idfapt2<-(number (pi ?i))
	?idfapt<-(suma (pi ?s))
	=>
	(bind ?s1 (+ ?i ?s))
	(modify ?idfapt (pi ?s1))
	;(printout t ?s1 crlf)
	(retract ?idfapt2)    
)

;af suma finala,o singura data , nu de fiecare data ca mai sus
(defrule print
    (suma (pi ?s))
    =>
    (printout t "suma este " ?s)
)





(run)